home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_06
/
8n06076a
< prev
next >
Wrap
Text File
|
1990-04-29
|
967b
|
47 lines
Listing 8:
#include <stdio.h>
#define MS_DOS_EOF 26
#define MS_DOS_CR 13
main(argc, argv)
/* Translate MS-DOS text file to UNIX file */
/**** Does not check for errors *****/
/* Usage translate file-in file-out */
int argc;
char *argv[];
{
int c;
FILE *file_in, file_out;
file_in = fopen(argv[1],"rb");
file_out = fopen(argv[2],"wb");
while (1)
{
c = fgetc(file_in);
switch(c)
{
case EOF:
case MS_DOS_EOF:
/* All done */
goto end;
break;
case MS_DOS_CR:
/* Ignore the CR value */
break;
default:
fputc(c, file_out);
break;
}
}
end:
fclose(file_in);
fclose(file_out);
exit(0);
}